package com.komodo.island.gdx.game.kodomosuit;

import java.util.Random;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.actors.Image;
import com.komodo.island.gdx.Art;
import com.komodo.island.gdx.Constants;
import com.komodo.island.gdx.Input;
import com.komodo.island.gdx.KomodoIsland;
import com.komodo.island.gdx.Persistence;
import com.komodo.island.gdx.StringNotif;
import com.komodo.island.gdx.dialog.LoseDialog;
import com.komodo.island.gdx.dialog.WinDialog;
import com.komodo.island.gdx.game.Time;
import com.komodo.island.gdx.screen.GameScreen;
import com.komodo.island.gdx.screen.Screen;

public class SuitKomodo extends GameScreen {

	private SuitKomodoStage suitKomodoStage;

	public final static int NUMBER_OF_SKILL = 3;

	public final static int SCISSORS = 0;
	public final static int PAPER = 1;
	public final static int ROCK = 2;

	/*
	 * Scissors versus Paper, scissors win Scissors versus Rock, scissors lose
	 * 
	 * Paper versus Rock, paper win Paper versus Scissors, paper lose
	 * 
	 * Rock versus Scissors, rock win Rock versus Paper, rock lose
	 */

	public final static int BITE = SCISSORS;
	public final static int STAND = PAPER;
	public final static int HEAD = ROCK;
	public final static int UNKNOWN = 3;

	/*
	 * Bite vs Stand, Bite win Bite vs Head, Bite lose
	 * 
	 * Stand vs Head, Stand win Stand vs Bite, Stand lose
	 * 
	 * Head vs Bite, Head win Head vs Stand, Head lose
	 */

	public final static int SUIT_LOSE = 0;
	public final static int SUIT_DRAW = 1;
	public final static int SUIT_WIN = 2;

	/*
	 * 
	 */
	private Random randomizer;
	private int playerCode = BITE;
	private int cpuCode = BITE;

	/*
	 * Love Point for Komodo Girl
	 */

	private int playerLP = 0;
	private int cpuLP = 0;

	private double regenTime;
	private double startRegen;
	private boolean isRegen;
	/*
	 * Button for player
	 */

	private TextureRegion cluesRegion[];
	// 0,1,2 head or stand
	// 3,4,5 head or bite
	// 6,7,8 bite or stand
	// 9 all
	private int clue;

	public Time time;

	private static final int SUIT_UNKNOWN = 999;

	public StringNotif stringNotification;
	public Texture suitTexture;

	private double second;

	public TextureRegion playerBiteRegion[][];
	public TextureRegion playerHeadRegion[][];
	public TextureRegion playerStandRegion[][];

	public TextureRegion cpuBiteRegion[][];
	public TextureRegion cpuHeadRegion[][];
	public TextureRegion cpuStandRegion[][];

	public PlayerKomodo playerBiteKomodo;
	public PlayerKomodo playerHeadKomodo;
	public PlayerKomodo playerStandKomodo;

	public PlayerKomodo cpuBiteKomodo;
	public PlayerKomodo cpuHeadKomodo;
	public PlayerKomodo cpuStandKomodo;

	private float stateTime;

	public Sound batu;
	public Sound lose;
	public Sound win;
	public Sound gunting;
	public Sound kertas;

	public SuitKomodo() {
		// TODO Auto-generated constructor stub
		ID = Input.SCREEN_GAME;
	}

	@Override
	public void init(KomodoIsland komodoIsland, Texture texture) {
		// TODO Auto-generated method stub
		super.init(komodoIsland, texture);
		previousScreen = komodoIsland.scientistScreen;

		if (stringNotification == null)
			this.stringNotification = new StringNotif(batch, "", 240 - 64,
					320 - 10 - 24, 500);

		if (time == null)
			this.time = new Time(0, 0);

		// playerButton = new TextureRegion[3];
		// playerButton[BITE] = new TextureRegion(texture, playerButtonX[BITE],
		// playerButtonY[BITE], 60, 60);
		// playerButton[STAND] = new TextureRegion(texture,
		// playerButtonX[STAND],
		// playerButtonY[STAND], 60, 60);
		// playerButton[HEAD] = new TextureRegion(texture, playerButtonX[HEAD],
		// playerButtonY[HEAD], 60, 60);

		if (randomizer == null)
			randomizer = new Random();
		// listOfPlayerButton = new ArrayList<Rectangle>(4);
		// listOfPlayerButton.add(new Rectangle(0, 0, 60, 60));
		// listOfPlayerButton.add(new Rectangle(60, 0, 60, 60));
		// listOfPlayerButton.add(new Rectangle(100, 100, 60, 60));

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.komodo.island.gdx.screen.GameScreen#onGameRunning()
	 * 
	 * game running, draw the ui, check input, whether the user choose bite,
	 * stand, or head... and then fight the cpu .. and then show the result...
	 */

	@Override
	public void onGameRunning() {
		// draw ui
		if (komodoIsland.input.dialogShow) {
			stateTime += Gdx.graphics.getDeltaTime();
			// System.out.println(stateTime/0.25f);
			suitKomodoStage.draw();
			time.runTime();
			Art.drawString("Time : " + Art.decimal2.format(time.getSecond()),
					480 - 200, 0);

			// Art.drawString(suitKomodoStage.getSpriteBatch(), "Head",
			// (int) suitKomodoStage.headButton.x, 60);
			// Art.drawString(suitKomodoStage.getSpriteBatch(), "Stand",
			// (int) suitKomodoStage.standButton.x, 60);
			// Art.drawString(suitKomodoStage.getSpriteBatch(), "Bite",
			// (int) suitKomodoStage.biteButton.x, 60);
			// Art.drawString(suitKomodoStage.getSpriteBatch(), "Player", 0,
			// 320 - 32);
			// Art.drawString(suitKomodoStage.getSpriteBatch(), playerLP + "",
			// 0,
			// 320 - 32 * 2);
			// Art.drawString(suitKomodoStage.getSpriteBatch(), "CPU",
			// 480 - 32 * 3, 320 - 32);
			// Art.drawString(suitKomodoStage.getSpriteBatch(), cpuLP + "",
			// 480 - 32 * 3, 320 - 32 * 2);

			if (isRegen) {
				regenTime = System.currentTimeMillis();
				Art.drawString("........", 0, 320 - 64 - 32);
				if (regenTime - startRegen >= 2000) {
					suitKomodoStage.addActor(suitKomodoStage.biteButton);
					suitKomodoStage.addActor(suitKomodoStage.headButton);
					suitKomodoStage.addActor(suitKomodoStage.standButton);
					clue = randomizer.nextInt(9); // random
					// 0,1,2 head or stand
					// 3,4,5 head or bite
					// 6,7,8 bite or stand
					// 9 all

					if ((clue == 0) || (clue == 1) || (clue == 2)) {
						if (randomizer.nextBoolean()) {
							cpuCode = HEAD;
						} else {
							cpuCode = STAND;
						}
					} else if ((clue == 3) || (clue == 4) || (clue == 5)) {
						if (randomizer.nextBoolean()) {
							cpuCode = HEAD;
						} else {
							cpuCode = BITE;
						}
					} else if ((clue == 6) || (clue == 7) || (clue == 8)) {
						if (randomizer.nextBoolean()) {
							cpuCode = STAND;
						} else {
							cpuCode = BITE;
						}
					} else {
						if (randomizer.nextBoolean()) {
							cpuCode = STAND;
						} else {
							cpuCode = BITE;
						}
					}
					// playerCode = UNKNOWN;
					// cpuCode = UNKNOWN;
					isRegen = false;
				} else {

					batch.begin();
					if (playerCode == BITE) {
						playerBiteKomodo.nextKey(stateTime);
						playerBiteKomodo.draw(batch);
					} else if (playerCode == HEAD) {
						playerHeadKomodo.nextKey(stateTime);
						playerHeadKomodo.draw(batch);
					} else if (playerCode == STAND) {
						playerStandKomodo.nextKey(stateTime);
						playerStandKomodo.draw(batch);
					}
					if (cpuCode == BITE) {
						cpuBiteKomodo.nextKey(stateTime);
						cpuBiteKomodo.draw(batch);
					} else if (cpuCode == HEAD) {
						cpuHeadKomodo.nextKey(stateTime);
						cpuHeadKomodo.draw(batch);
					} else if (cpuCode == STAND) {
						cpuStandKomodo.nextKey(stateTime);
						cpuStandKomodo.draw(batch);
					}

					batch.end();
				}

			} else {
				// draw clue
				// Art.drawString(clueclue[clue], 0, 240);
				batch.begin();
				batch.draw(cluesRegion[clue], 0, 320 - 64 - 32);
				batch.end();

			}

			stringNotification.draw();

		}

		// check result

		if (playerLP >= 100) {
			score += time.getSecond() * 100;
			setGameToWin();
		} else if (cpuLP >= 100) {
			score = 0;
			setGameToLose();
		}

		if (time.getMinute() == 0 && (Math.ceil(time.getSecond()) == 0)) {
			if (playerLP > cpuLP) {
				if (playerLP < 100)
					setGameToWin();
			} else {
				score = 0;
				setGameToLose();
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.komodo.island.gdx.screen.GameScreen#onGameWin() handle condition
	 * when player win the game
	 */
	@Override
	public void onGameWin() {
		// draw the ui
		// Art.drawString("You Win", 0, 320 - 32);
		// Art.drawString("" + score, 0, 320 - 32);

	}

	@Override
	public void onGameLose() {

	}

	@Override
	public void onGamePause() {
		// do everything when the game is paused...

	}

	@Override
	public void onGameStart() {
		// initialize anything before starting the game ...
		// initialize the code -> player attack, and cpu attack
		cpuCode = UNKNOWN;
		playerCode = UNKNOWN;
		// initialize the love point for all player ...
		score = 0;
		cpuLP = 0;
		playerLP = 0;
		time.setMinute(0);
		time.setSecond(60);
		isRegen = true;
		startRegen = System.currentTimeMillis();

		try {
			suitKomodoStage.removeActor(suitKomodoStage.headButton);
			suitKomodoStage.removeActor(suitKomodoStage.biteButton);
			suitKomodoStage.removeActor(suitKomodoStage.standButton);
		} catch (Exception e) {

		}

	}

	public void buttonClicked(int index) {
		// fill this method as the effect whenever the button is clicked ...

		int temp;
		// set the code for player and cpu
		switch (index) {
		case BITE: {
			playerCode = BITE;
			break;
		}
		case STAND: {
			playerCode = STAND;
			break;
		}
		case HEAD: {
			playerCode = HEAD;
			break;
		}
		}

		// check winner,
		int result = checkWinner();

		// affect the love point by the result of the fight
		if (result == SUIT_WIN) {
			// player won
			stringNotification.notif = "You Win";
			stringNotification.show();
			// System.out.println("Suit Menang");
			affectPlayerLovePoint(10 + randomizer.nextInt(5));
			// affectCPULovePoint(-(1 + randomizer.nextInt(5)));
			score += 400;
			if (Persistence.sound) {
				win.play(1);
			}
		} else if (result == SUIT_LOSE) {
			// player lose
			stringNotification.notif = "You Lose";
			stringNotification.show();
			// System.out.println("Suit Kalah");
			// affectPlayerLovePoint(-(1 + randomizer.nextInt(5)));
			affectCPULovePoint(10 + randomizer.nextInt(5));
			if (Persistence.sound) {
				lose.play(1);
			}
		} else if (result == SUIT_DRAW) {
			// player draw
			stringNotification.notif = "You Draw";
			stringNotification.show();
			// affectPlayerLovePoint(-(1 + randomizer.nextInt(1)));
			// affectCPULovePoint(-(1 + randomizer.nextInt(1)));
			score -= 100;
		} else {
			// result unknown
		}
		// revert back the code to unknown (the default value)

		suitKomodoStage.removeActor(suitKomodoStage.biteButton);
		suitKomodoStage.removeActor(suitKomodoStage.standButton);
		suitKomodoStage.removeActor(suitKomodoStage.headButton);
		startRegen = System.currentTimeMillis();

		// playerKomodo.startKey(4);
		// playerKomodo.setNewAnimation(newAnim)
		// playerKomodo.set
		isRegen = true;

	}

	private void affectPlayerLovePoint(int point) {
		// change player's love point
		suitKomodoStage.increasePlayerBar(point);
		if (point + playerLP <= 0) {
			playerLP = 0;
		} else if (point + playerLP >= 100) {
			playerLP = 100;
		} else {
			playerLP += point;
		}

	}

	private void affectCPULovePoint(int point) {
		// change cpu's love point
		suitKomodoStage.increaseCpuBar(point);
		if (point + cpuLP <= 0) {
			cpuLP = 0;
		} else if (point + cpuLP >= 100) {
			cpuLP = 100;
		} else {
			cpuLP += point;
		}

	}

	private int checkWinner() {
		// check winner
		switch (playerCode) {
		case BITE: {
			switch (cpuCode) {
			case BITE: {
				return SUIT_DRAW;
			}
			case HEAD: {
				return SUIT_LOSE;
			}
			case STAND: {
				return SUIT_WIN;
			}
			}
			break;
		}
		case STAND: {
			switch (cpuCode) {
			case BITE: {
				return SUIT_LOSE;
			}
			case HEAD: {
				return SUIT_WIN;
			}
			case STAND: {
				return SUIT_DRAW;
			}
			}
			break;
		}
		case HEAD: {
			switch (cpuCode) {
			case BITE: {
				return SUIT_WIN;
			}
			case HEAD: {
				return SUIT_DRAW;
			}
			case STAND: {
				return SUIT_LOSE;
			}
			}
			break;
		}
		}
		return SUIT_UNKNOWN;
	}

	@Override
	public void setScreenToRun() {
		// TODO Auto-generated method stub
		super.setScreenToRun();
		komodoIsland.input.setStage(suitKomodoStage);
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		super.dispose();

	}

	@Override
	public void cleanResScreen() {
		// TODO Auto-generated method stub
		super.cleanResScreen();
		try {
			suitKomodoStage.dispose();
			suitTexture.dispose();
		} catch (Exception e) {

		}
	}

	protected class SuitWinDialog extends WinDialog {

		public Image finish;

		public SuitWinDialog(float width, float height, boolean stretch,
				Screen screen, Texture texture, KomodoIsland komodoIsland) {
			super(width, height, stretch, screen, texture, komodoIsland);
			// TODO Auto-generated constructor stub
		}

		@Override
		public void init() {
			// TODO Auto-generated method stub
			super.init();
			finish = new Image("finish", new TextureRegion(
					screen.komodoIsland.additionTexture, 192, 760, 145, 96));

		}

		@Override
		public void addElements() {
			// TODO Auto-generated method stub
			super.addElements();
			addActor(finish);
		}

		@Override
		public void setThePosition() {
			// TODO Auto-generated method stub
			super.setThePosition();
			finish.x = text.x - 145 - 10;
			finish.y = bgImage.y + bgImage.height - finish.height;
		}

	}

	protected class SuitLoseDialog extends LoseDialog {

		public Image finish;

		public SuitLoseDialog(float width, float height, boolean stretch,
				Screen screen, Texture texture, KomodoIsland komodoIsland) {
			super(width, height, stretch, screen, texture, komodoIsland);
			// TODO Auto-generated constructor stub
		}

		@Override
		public void init() {
			// TODO Auto-generated method stub
			super.init();
			finish = new Image("finish", new TextureRegion(
					screen.komodoIsland.additionTexture, 192 + 145, 760, 145,
					96));
		}

		@Override
		public void addElements() {
			// TODO Auto-generated method stub
			super.addElements();
			addActor(finish);
		}

		@Override
		public void setThePosition() {
			// TODO Auto-generated method stub
			super.setThePosition();
			finish.x = text.x - 145 - 10;
			finish.y = bgImage.y + bgImage.height - finish.height;
		}

	}

	@Override
	protected void onGameLoading() {
		// TODO Auto-generated method stub

		if (komodoIsland.suit == null) {
			komodoIsland.suit = Gdx.audio.newMusic(Gdx.files
					.internal("bgm/suit.wav"));
			komodoIsland.suit.setLooping(true);
			komodoIsland.suit.setVolume(0.5f);
		}

		if (batu == null) {
			batu = Gdx.audio.newSound(Gdx.files.internal("sfx/suit/batu.wav"));
		}
		if (win == null) {
			win = Gdx.audio.newSound(Gdx.files.internal("sfx/suit/win.wav"));
		}
		if (lose == null) {
			lose = Gdx.audio.newSound(Gdx.files.internal("sfx/suit/lose.wav"));
		}
		if (gunting == null) {
			gunting = Gdx.audio.newSound(Gdx.files
					.internal("sfx/suit/gunting.wav"));
		}
		if (kertas == null) {
			kertas = Gdx.audio.newSound(Gdx.files
					.internal("sfx/suit/kertas.wav"));
		}

		if (Persistence.sound) {
			try {
				if (!komodoIsland.suit.isPlaying()) {
					komodoIsland.suit.play();
				}
			} catch (Exception e) {

			}
		}

		if (suitTexture == null)
			suitTexture = new Texture(Gdx.files.internal("suit1.png"));
		if (suitKomodoStage == null)
			this.suitKomodoStage = new SuitKomodoStage(480, 320, true, this,
					suitTexture, komodoIsland);

		suitKomodoStage.resetBar();

		if (winDialog == null)
			this.winDialog = new SuitWinDialog(Constants.GAME_WIDTH,
					Constants.GAME_HEIGHT, true, this,
					komodoIsland.dialogTexture, komodoIsland);
		if (loseDialog == null)
			this.loseDialog = new SuitLoseDialog(Constants.GAME_WIDTH,
					Constants.GAME_HEIGHT, true, this,
					komodoIsland.dialogTexture, komodoIsland);

		if (cluesRegion == null) {
			cluesRegion = new TextureRegion[9];
			// 0,1,2 head or stand
			// 3,4,5 head or bite
			// 6,7,8 bite or stand
			cluesRegion[3] = new TextureRegion(suitTexture, 0, 320, 480, 32);
			cluesRegion[4] = new TextureRegion(suitTexture, 0, 320 + 32, 480,
					32);

			cluesRegion[0] = new TextureRegion(suitTexture, 0, 320 + 32 * 2,
					480, 32);
			cluesRegion[1] = new TextureRegion(suitTexture, 0, 320 + 32 * 3,
					480, 32);
			cluesRegion[2] = new TextureRegion(suitTexture, 0, 320 + 32 * 4,
					480, 32);

			cluesRegion[6] = new TextureRegion(suitTexture, 0, 320 + 32 * 5,
					480, 32);
			cluesRegion[7] = new TextureRegion(suitTexture, 0, 320 + 32 * 6,
					480, 32);
			cluesRegion[8] = new TextureRegion(suitTexture, 0, 320 + 32 * 7,
					480, 32);

			cluesRegion[5] = new TextureRegion(suitTexture, 0, 320 + 32 * 8,
					480, 32);

		}

		playerBiteRegion = new TextureRegion[2][6];
		playerBiteRegion[0] = new TextureRegion[3];
		// playerBiteRegion[0][0] = new TextureRegion(suitTexture, 480, 680,
		// 150,
		// 150);
		playerBiteRegion[0][0] = new TextureRegion(suitTexture, 480 + 150, 680,
				150, 170);
		playerBiteRegion[0][1] = new TextureRegion(suitTexture, 480 + 150 * 2,
				680, 150, 170);
		playerBiteRegion[0][2] = new TextureRegion(suitTexture, 480 + 150 * 3,
				680, 150, 170);
		// playerBiteRegion[0][4] = new TextureRegion(suitTexture, 480 + 150 *
		// 4,
		// 680, 150, 170);
		// playerBiteRegion[0][5] = new TextureRegion(suitTexture, 480 + 150 *
		// 5,
		// 680, 150, 170);

		playerHeadRegion = new TextureRegion[2][6];
		playerHeadRegion[0] = new TextureRegion[3];
		playerHeadRegion[0][0] = new TextureRegion(suitTexture, 480, 0, 200,
				170);
		playerHeadRegion[0][1] = new TextureRegion(suitTexture, 480 + 200, 0,
				200, 170);
		playerHeadRegion[0][2] = new TextureRegion(suitTexture, 480 + 200 * 2,
				0, 200, 170);
		// playerHeadRegion[0][3] = new TextureRegion(suitTexture, 480 + 200 *
		// 3,
		// 0, 200, 170);
		// playerHeadRegion[0][4] = new TextureRegion(suitTexture, 480 + 200 *
		// 4,
		// 0, 200, 170);

		playerStandRegion = new TextureRegion[2][6];
		playerStandRegion[0] = new TextureRegion[4];
		playerStandRegion[0][0] = new TextureRegion(suitTexture, 480, 510, 150,
				170);
		playerStandRegion[0][1] = new TextureRegion(suitTexture, 480 + 150,
				510, 150, 170);
		playerStandRegion[0][2] = new TextureRegion(suitTexture, 480 + 150 * 2,
				510, 150, 170);
		playerStandRegion[0][3] = new TextureRegion(suitTexture, 480 + 150 * 3,
				510, 150, 170);
		// playerStandRegion[0][4] = new TextureRegion(suitTexture, 480 + 150 *
		// 4,
		// 510, 150, 170);
		// playerStandRegion[0][5] = new TextureRegion(suitTexture, 480 + 150 *
		// 5,
		// 510, 150, 170);

		playerBiteKomodo = new PlayerKomodo(playerBiteRegion[0], 3);
		playerBiteKomodo.setPosition(480 / 2 - 200, 64);

		playerHeadKomodo = new PlayerKomodo(playerHeadRegion[0], 4);
		playerHeadKomodo.setPosition(playerBiteKomodo.getX(),
				playerBiteKomodo.getY());

		playerStandKomodo = new PlayerKomodo(playerStandRegion[0], 4);
		playerStandKomodo.setPosition(playerBiteKomodo.getX(),
				playerBiteKomodo.getY());

		//
		cpuBiteRegion = new TextureRegion[2][6];
		cpuBiteRegion[0] = new TextureRegion[3];
		// cpuBiteRegion[0][0] = new TextureRegion(suitTexture, 480, 850, 150,
		// 170);
		cpuBiteRegion[0][0] = new TextureRegion(suitTexture, 480 + 150, 850,
				150, 170);
		cpuBiteRegion[0][1] = new TextureRegion(suitTexture, 480 + 150 * 2,
				850, 150, 170);
		cpuBiteRegion[0][2] = new TextureRegion(suitTexture, 480 + 150 * 3,
				850, 150, 170);

		cpuHeadRegion = new TextureRegion[2][6];
		cpuHeadRegion[0] = new TextureRegion[3];
		cpuHeadRegion[0][0] = new TextureRegion(suitTexture, 480, 170, 200, 170);
		cpuHeadRegion[0][1] = new TextureRegion(suitTexture, 480 + 200, 170,
				200, 170);
		cpuHeadRegion[0][2] = new TextureRegion(suitTexture, 480 + 200 * 2,
				170, 200, 170);

		cpuStandRegion = new TextureRegion[2][6];
		cpuStandRegion[0] = new TextureRegion[4];
		cpuStandRegion[0][0] = new TextureRegion(suitTexture, 480, 340, 150,
				170);
		cpuStandRegion[0][1] = new TextureRegion(suitTexture, 480 + 150, 340,
				150, 170);
		cpuStandRegion[0][2] = new TextureRegion(suitTexture, 480 + 150 * 2,
				340, 150, 170);
		cpuStandRegion[0][3] = new TextureRegion(suitTexture, 480 + 150 * 3,
				340, 150, 170);

		cpuBiteKomodo = new PlayerKomodo(cpuBiteRegion[0], 3);
		cpuBiteKomodo.setPosition(480 / 2 + 32, 64);

		cpuHeadKomodo = new PlayerKomodo(cpuHeadRegion[0], 4);
		cpuHeadKomodo.setPosition(cpuBiteKomodo.getX(), cpuBiteKomodo.getY());
		cpuStandKomodo = new PlayerKomodo(cpuStandRegion[0], 4);
		cpuStandKomodo.setPosition(cpuBiteKomodo.getX(), cpuBiteKomodo.getY());

	}

	@Override
	protected boolean onGameStartAnimation() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		super.hide();
		try {
			if (Persistence.sound) {
				if (komodoIsland.suit.isPlaying()) {
					komodoIsland.suit.stop();
				}
			} else {

			}
		} catch (Exception e) {

		}
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		super.show();
		try {
			if (Persistence.sound) {
				if (!komodoIsland.suit.isPlaying()) {
					komodoIsland.suit.play();
				}
			} else {

			}
		} catch (Exception e) {

		}
	}

	@Override
	public void exitScreen() {
		// TODO Auto-generated method stub
		try {
			suitKomodoStage.dispose();
			batu.dispose();
			kertas.dispose();
			gunting.dispose();
			win.dispose();
			lose.dispose();
			suitTexture.dispose();
			suitKomodoStage = null;
			suitTexture = null;
			batu = null;
			gunting = null;
			kertas = null;
			win = null;
			lose = null;

			System.gc();
		} catch (Exception e) {

		}
		super.exitScreen();
	}
}
